package com.shuoyue.ycgk.views.dialog.addresspicker;

import android.graphics.Color;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseViewHolder;
import com.shuoyue.ycgk.R;
import com.shuoyue.ycgk.base.baseadapter.AppBaseQuickAdapter;
import com.shuoyue.ycgk.entity.address.AddressBean;

import java.util.List;

public class PickerAdapter extends AppBaseQuickAdapter<AddressBean> {
    public PickerAdapter(@Nullable List<AddressBean> data) {
        super(R.layout.item_picker, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, AddressBean item) {
        helper.addOnClickListener(R.id.title);
        helper.setText(R.id.title, item.getName());
        helper.setTextColor(R.id.title, Color.parseColor(item.isSelect() ? "#06A0DC" : "#000000"));
    }

    public AddressBean getSelect() {
        for (AddressBean bean : mData) {
            if (bean.isSelect()) {
                return bean;
            }
        }
        return null;
    }
}
